<?php 
include '../common.php';
	
	$a = $_GET['a'];
	
	switch($a){
		case 'addshow':
			$cate = $_POST['cate'];
			$style = $_POST['style'];
			$sql = "insert into ".PRE."homepage(cate_id,style) values('{$cate}','{$style}')";
			mysql_query($sql);
			header('Location:'.$_SERVER['HTTP_REFERER']);
			break;

		case 'delshow':
			$id = $_GET['id'];
			$sql = "delete from ".PRE."homepage where id='{$id}'";
			mysql_query($sql);
			header('Location:'.$_SERVER['HTTP_REFERER']);
			break;

		case 'rec':
			$id = $_GET['id'];
			$value = $_GET['value'];
			$sql = "update ".PRE."homepage set recommend='{$value}' where id='{$id}'";
			mysql_query($sql);
			header('Location:'.$_SERVER['HTTP_REFERER']);
			break;
		case 'addbanner':
			$category = $_POST['cate'];
			$style =$_POST['style'];
			$name = upload('pic' ,PATH.'/../upload/');
			if(!simzoom(PATH.'/../upload/',$name,1200)){
				@unlink(PATH.'/../upload/'.$name);
				header('Location:'.$_SERVER['HTTP_REFERER']);
			}
			//删除上传后的原尺寸的图片（没用）
			@unlink(PATH.'/../upload/'.$name); 
			//写入数据库
			$name = '1200_'.$name;
			$sql = "insert into ".PRE."image(name,cate_id,style,size) values('{$name}','{$category}','{$style}','1')";
			mysql_query($sql);
			header('Location:'.$_SERVER['HTTP_REFERER']);
			break;
			
		case 'addbrand':
			$category = $_POST['cate'];
			$style =$_POST['style'];
			$name = upload('pic' ,PATH.'/../upload/');
			if(!simzoom(PATH.'/../upload/',$name,580)){
				@unlink(PATH.'/../upload/'.$name);
				header('Location:'.$_SERVER['HTTP_REFERER']);
			}
			//删除上传后的原尺寸的图片（没用）
			@unlink(PATH.'/../upload/'.$name); 
			//写入数据库
			$name = '580_'.$name;
			$sql = "insert into ".PRE."image(name,cate_id,style,size) values('{$name}','{$category}','{$style}','2')";
			mysql_query($sql);
			header('Location:'.$_SERVER['HTTP_REFERER']);
			break;
			
		case 'dis':
			$id = $_GET['id'];
			$value = $_GET['value'];
			$sql = "update ".PRE."image set `display`='{$value}' where id='{$id}'";
			mysql_query($sql);
			header('Location:'.$_SERVER['HTTP_REFERER']);
			break;
			
		case 'delbanner':
			$id = $_GET['id'];
			$name = $_GET['name'];
			@unlink(PATH.'/../upload/'.$name);
			$sql = "delete from ".PRE."image where id='{$id}'";
			mysql_query($sql);
			header('Location:'.$_SERVER['HTTP_REFERER']);
			break;
	
	
	}
